import { createStore } from 'vuex'
import getters from '@/store/getters'

const modulesFiles = require.context('./modules', true, /\.js$/)

const modules = modulesFiles.keys().reduce((modules, modulePath) => {
  // set './app.js' => 'app'
  const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
  const value = modulesFiles(modulePath)
  modules[moduleName] = value.default
  return modules
}, {})

const store = createStore({
  modules,
  getters
})

export default store
// const state = {}
// const mutations = {}
// const actions = {}
//
// export default {
//   namespace: true,
//   state,
//   mutations,
//   actions
// }
